package com.wang.thread;

public class ThreadDemo {
    public static void main(String[] args) throws Exception {
        int size1 = Thread.currentThread().getThreadGroup().activeCount();
        System.out.println("real thread size:" + size1);
        EasyThreadPool threadPool = new EasyThreadPool(4,8, System.out::println);
        for (int i = 0; i < 20; i++) {
            threadPool.addTask(()->{
                int size = Thread.currentThread().getThreadGroup().activeCount();
                System.out.println("real thread size:" + size);
                System.out.println("task:" + System.currentTimeMillis() / 1000);
            });
        }
        Thread.sleep(8000);
        System.out.println("ts:" + threadPool.getThreadSize());
        for (int i = 0; i < 20; i++) {
            Thread.sleep(1000);
            threadPool.addTask(()->{
                int size = Thread.currentThread().getThreadGroup().activeCount();
                System.out.println("real thread size:" + size);
                System.out.println("thread size:" + threadPool.getThreadSize());
            });
        }
    }
}
